package com.example.suanfademo;

public class ThreadLoadExample {
    private static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    public static void main(String[] args) {
        // 设置线程局部变量的值
        threadLocal.set(10);

        // 这个值在其他线程中是取不到获取的
        new Thread(() -> {
            Integer value = threadLocal.get();//null
            System.out.println("Thread value: " + value);
        }).start();
    }

}
